import logging

def get_log(name='test_logger'):
    logger=logging.getLogger(name)
    if not logger.handlers:
        fmt=logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        # 1.文件输出
        file_hd=logging.FileHandler('rizhi.log',encoding='utf-8')
        file_hd.setFormatter(fmt)
        logger.addHandler(file_hd)
        # 控制台输出
        kong_hd=logging.StreamHandler()
        kong_hd.setFormatter(fmt)
        logger.addHandler(kong_hd)

        logger.setLevel(logging.INFO)
    return logger